PasswordFiled char[] to String in Java connection MySql?
Posted
by
user1819551
on Stack Overflow
See other posts from Stack Overflow
or by user1819551
Published on 2012-12-06T17:01:55Z
Indexed on
2012/12/06
17:03 UTC
Read the original article
Hit count: 149
java
This is a jFrame to connect to the database and this is in the button connect. My issue is in the passwordField NetBeans make me do a char[], but my .getConnection not let me insert the char[] ERROR: "no suitable method found for getConnection(String,String,char[])". So I will change to String right? So when I change and run the jFrame said access denied. when I start doing the System.out.println(l) " Give me the right answer" Like this: "Alex". But when I do the System.out.println(password) "Give me the Array spaces and not the value" Like this: jdbc:mysql://localhost/home inventory root [C@5be5ab68 <--- Array space . What I doing wrong?
try {
Class.forName("org.gjt.mm.mysql.Driver"); //Load the driver
String host = "jdbc:mysql://"+tServerHost.getText()+"/"+tSchema.getText();
String uName = tUsername.getText();
char[] l = pPassword.getPassword();
System.out.println(l);
String password= l.toString();
System.out.println(host+uName+l);
con = DriverManager.getConnection(host, uName, password);
System.out.println(host+uName+password);
} catch (SQLException | ClassNotFoundException ex) {
JOptionPane.showMessageDialog(this, ex.getMessage());
}
}
© Stack Overflow or respective owner